import { Component, EventEmitter, Input, OnDestroy, OnInit, Output } from "@angular/core";
import { Router } from "@angular/router";
import { MyhttpService } from "../myhttp.service";
import { CommService } from "../comm-service";
import { LocalStorageService } from "../local-storage-service";

declare var $: any;

@Component({
  selector: 'fzjc-title',
  template: `
    <div class="fzjcroom bgdiv">
      <div class="fzjcbg bgdiv"></div>
      <div class="title">
        {{titlev}}
      </div>
      <div class="lroom">
        <div class="kstime bgdiv fl">
          {{nowtimelabel}}
        </div>
        <div class="pageicons fl" *ngIf="pageiconlist.length">
          <ng-container *ngFor="let pageicon of pageiconlist">
            <div *ngIf="pageicon.page==='basedeft'" class="fl">
              <div [ngClass]="{'basedeftclass':!pageicon.active,'basedeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <div *ngIf="pageicon.page==='sjgzdeft'" class="fl">
              <div [ngClass]="{'sjgzdeftclass':!pageicon.active,'sjgzdeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <div *ngIf="pageicon.page==='bmszsdeft'" class="fl">
              <div [ngClass]="{'bmszsdeftclass':!pageicon.active,'bmszsdeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <div *ngIf="pageicon.page==='kqzldeft'" class="fl">
              <div [ngClass]="{'kqzldeftclass':!pageicon.active,'kqzldeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <div *ngIf="pageicon.page==='khtjdeft'" class="fl">
              <div [ngClass]="{'khtjdeftclass':!pageicon.active,'khtjdeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <div *ngIf="pageicon.page==='sphydeft'" class="fl">
              <div [ngClass]="{'sphydeftclass':!pageicon.active,'sphydeftclassing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <!--<div *ngIf="pageicon.page==='kqzldeft2'" class="fl">-->
            <!--<div [ngClass]="{'kqzldeft2class':!pageicon.active,'kqzldeft2classing':pageicon.active}"-->
            <!--class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc">{{pageicon.mc}}-->
            <!--</div>-->
            <!--</div>-->
            <!--<div *ngIf="pageicon.page==='kqzldeft3'" class="fl">-->
            <!--<div [ngClass]="{'kqzldeft3class':!pageicon.active,'kqzldeft3classing':pageicon.active}"-->
            <!--class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>-->
            <!--</div>-->
            <div *ngIf="pageicon.page==='p1deft'" class="fl">
              <div [ngClass]="{'p1class':!pageicon.active,'p1classing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
            <!--<div *ngIf="pageicon.page==='p11deft'" class="fl">-->
            <!--<div [ngClass]="{'p1class':!pageicon.active,'p1classing':pageicon.active}"-->
            <!--class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>-->
            <!--</div>-->
            <div *ngIf="pageicon.page==='p2deft'" class="fl">
              <div [ngClass]="{'p1class':!pageicon.active,'p1classing':pageicon.active}"
                   class="bgdiv" (click)="goto(pageicon);" [title]="pageicon.mc"></div>
            </div>
          </ng-container>
        </div>
      </div>
      <div class="rroom">
        <div class="rbtns fr" *ngIf="rbtnlist.length">
          <ng-container *ngFor="let btn of rbtnlist">
            <div *ngIf="btn.btnkey==='arrow'" class="fr">
              <div [ngClass]="{'arrowdeftclass':!btn.active,'arrowdeftclassing':btn.active}"
                   class="bgdiv" (click)="btnHander(btn);" [title]="btn.mc"></div>
            </div>
            <div *ngIf="btn.btnkey==='runsphy'" class="fr">
              <div [ngClass]="{'runsphydeftclass':!btn.active,'runsphydeftclassing':btn.active}"
                   class="bgdiv" (click)="btnHander(btn);" [title]="btn.mc"></div>
            </div>
            <div *ngIf="btn.btnkey==='hylist'" class="fr">
              <div [ngClass]="{'runsphydeftclass':!btn.active,'runsphydeftclassing':btn.active}"
                   class="bgdiv" (click)="btnHander(btn);" [title]="btn.mc"></div>
            </div>
            <div *ngIf="btn.btnkey==='ksccselect'" class="fr">
              <div [ngClass]="{'ksccselectclass':!btn.active,'ksccselectclassing':btn.active}"
                   class="bgdiv" (click)="btnHander(btn);" [title]="btn.mc">
                <!--考试计划考试场次-->
                <div id="ksccroom">
                  <iframe frameBorder='1' marginHeight='0' marginWidth='0'></iframe>
                  <div class="kscc">
                    <span class="mc" (click)="showccSelect($event)">{{nowccmc}}</span>
                    <span class="icon" (click)="showccSelect($event)">
             <i class="fa fa-caret-down" *ngIf="ksccselectShow"></i>
               <i class="fa fa-caret-left" *ngIf="!ksccselectShow"></i>
            </span>
                    <ul id="ksccFzjc" *ngIf="ksccArr.length">
                      <li *ngFor="let item of ksccArr" (click)="selectSure($event,2,item)">{{item.ccmc}}</li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
            <div *ngIf="btn.btnkey==='xsfa'" class="fr">
              <div [ngClass]="{'xsfaclass':!btn.active,'xsfaclassing':btn.active}"
                   class="bgdiv" (click)="btnHander(btn);" [title]="btn.mc">
                <div id="yamenu">
                  <iframe frameBorder='1' marginHeight='0' marginWidth='0'></iframe>
                  <ul>
                    <li (click)="selectSure($event,3,'setdefault')">
                      <i class="fa fa-cog"></i> 置为默认布局
                    </li>
                    <li (click)="selectSure($event,3,'add')">
                      <i class="fa fa-plus"></i> 添加布局预案
                    </li>
                    <div class="line"></div>
                    <li style="text-align: center" (click)="selectSure($event,3,'stopmp')">
                      <div style="height: 30px;line-height: 30px"><i class="fa fa-bars"></i> 布局预案列表</div>
                      <select id="yaselect" (change)="selectSure($event,3,'yatoggle')"></select>
                    </li>
                  </ul>
                </div>
              </div>
            </div>
          </ng-container>
        </div>
        <div class="rmc fr">
          <div class="date fr">{{nowtime}}</div>
          <div class="weather fr">欢迎 {{nowrolename}} 登入!</div>
        </div>
      </div>
    </div>

  `,
  styles: [
    ".bgdiv{background-size: 100% 100%;background-repeat: no-repeat}",
    ".fl{float: left}",
    ".fr{float: right}",
    ".fzjcroom{position: relative;width: 1920px;height: 90px;background-color: #012549;}",
    ".fzjcroom>.fzjcbg{position: absolute;left: 0px;top: 52px; width: 100%;height: 38px;background-image: url('assets/img/fzjc/p_tbg.png');}",
    ".fzjcroom>.title{position: absolute;left: 595px;top: 10px;width: 730px;height: calc(80px - 16px);text-align: center; line-height: 64px;font-weight: bolder;color: #ffffff;font-size: 40px;}",
    // ######### 左侧主页面导航
    ".fzjcroom>.lroom{position: absolute;left: 0px;bottom: 14px;width: 595px;height: 55px;}",
    ".lroom>.kstime{width: 115px; height: 55px;line-height: 55px;text-align: center;font-size: 20px;color: #56ccec; background-image: url('assets/img/fzjc/p_timelinebg.png');}",
    ".lroom>.pageicons{width: auto;height: auto}",
    //basedeft
    ".pageicons .basedeftclass{margin-left: 20px; width: 22px;height: 30px;margin-top: 11px;background-image: url('assets/img/fzjc/p_basedeft.png');cursor: pointer}",
    ".pageicons .basedeftclassing{margin-left: 20px; width: 22px;height: 30px;margin-top: 11px;background-image: url('assets/img/fzjc/p_basedeft1.png');cursor: pointer}",
    // sjgzdeft
    ".pageicons .sjgzdeftclass{margin-left: 20px; width: 32px;height: 25px;margin-top: 15px;background-image: url('assets/img/fzjc/p_sjgzdeft.png');cursor: pointer}",
    ".pageicons .sjgzdeftclassing{margin-left: 20px; width: 32px;height: 25px;margin-top: 15px;background-image: url('assets/img/fzjc/p_sjgzdeft1.png');cursor: pointer}",
    // bmszsdeft
    ".pageicons .bmszsdeftclass{margin-left: 20px;width: 27px;height: 27px;margin-top: 14px;background-image: url('assets/img/fzjc/p_bmszsdeft.png');cursor: pointer}",
    ".pageicons .bmszsdeftclassing{margin-left: 20px;width: 27px;height: 27px;margin-top: 14px;background-image: url('assets/img/fzjc/p_bmszsdeft1.png');cursor: pointer}",
    // kqzldeft
    ".pageicons .kqzldeftclass{margin-left: 20px;width: 30px;height: 25px;margin-top: 15px;background-image: url('assets/img/fzjc/p_kqzldeft.png');cursor: pointer}",
    ".pageicons .kqzldeftclassing{margin-left: 20px;width: 30px;height: 25px;margin-top: 15px;background-image: url('assets/img/fzjc/p_kqzldeft1.png');cursor: pointer}",
    // khtjdeft
    ".pageicons .khtjdeftclass{margin-left: 20px;width: 27px;height: 30px;margin-top: 12.5px;background-image: url('assets/img/fzjc/p_khtjdeft.png');cursor: pointer}",
    ".pageicons .khtjdeftclassing{margin-left: 20px;width: 27px;height: 30px;margin-top: 12.5px;background-image: url('assets/img/fzjc/p_khtjdeft1.png');cursor: pointer}",
    //sphydeft
    ".pageicons .sphydeftclass{margin-left: 20px;width: 27px;height: 30px;margin-top: 12.5px;background-image: url('assets/img/fzjc/p_sphydeft.png');cursor: pointer}",
    ".pageicons .sphydeftclassing{margin-left: 20px;width: 27px;height: 30px;margin-top: 12.5px;background-image: url('assets/img/fzjc/p_sphydeft1.png');cursor: pointer}",
    //总览1
    ".pageicons .kqzldeft2class{width: 115px; height: 55px;line-height: 55px;text-align: center;font-size: 20px;color: #56ccec; background-image: url('assets/img/fzjc/p_timelinebg.png');cursor: pointer}",
    ".pageicons .kqzldeft2classing{color:#F6CD69;width: 115px; height: 55px;line-height: 55px;text-align: center;font-size: 20px; background-image: url('assets/img/fzjc/p_timelinebg2.png');background-position: 7.5px 2px;background-size:96% 100%;cursor: pointer}",
    //总览2
    ".pageicons .kqzldeft3class{width: 28px;height: 28px;margin-top: 14px;background-image: url('assets/img/fzjc/p_zl01.png');cursor: pointer}",
    ".pageicons .kqzldeft3classing{width: 28px;height: 28px;margin-top: 14px;background-image: url('assets/img/fzjc/p_zl02.png');cursor: pointer}",
    //p1 p2
    ".pageicons .p1class{margin-left: 20px;width: 28px;height: 27px;margin-top: 14px;background-image: url('assets/img/fzjc/p_p101.png');cursor: pointer}",
    ".pageicons .p1classing{margin-left: 20px;width: 28px;height: 27px;margin-top: 14px;background-image: url('assets/img/fzjc/p_p102.png');cursor: pointer}",

    // 右侧 按钮和提示信息
    ".fzjcroom>.rroom{position: absolute;right: 5px;bottom: 14px;width: 595px;height: 55px;}",
    ".rroom>.rbtns{width: auto;height: auto}",
    ".rroom>.rmc{width: auto;height:55px;}",
    // 退出
    ".rbtns .arrowdeftclass{position: relative; width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/back.png');cursor: pointer}",
    ".rbtns .arrowdeftclassing{position: relative;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btn11.png');cursor: pointer}",
    // 一键开启视频会议
    ".rbtns .runsphydeftclass{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btn2.png');cursor: pointer}",
    ".rbtns .runsphydeftclassing{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btn22.png');cursor: pointer}",
    // 考试场次显示控制
    ".rbtns .ksccselectclass{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btn3.png');cursor: pointer}",
    ".rbtns .ksccselectclassing{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btn33.png');cursor: pointer}",
    "#ksccroom{display: none; position: absolute;right: 0px;top:45px;width: 152px;z-index:1;}",
    // 考试场次选中显示
    "#ksccroom>.kscc{position:relative;width: 152px;height: 30px;padding: 0px 10px;border: 2px solid #2a95bc;background-color: #002446;}",
    ".kscc>.mc{display: inline-block;width:122px;height:30px; line-height: 30px; font-size: 15px;color: #35bee3;overflow: hidden}",
    ".kscc>.icon{position: absolute;right: 10px;top: 0px;color: #35bee3;line-height: 30px;cursor: pointer}",
    // 考试场次下拉
    ".kscc>#ksccFzjc{display:none;position: absolute;list-style: none;margin: 0px;padding: 0px 10px; top: 30px;left:-2px;width: 154px;max-height: 80px;overflow-y: auto;overflow-x: hidden; border:2px solid #2a95bc;background-color: #002446;}",
    ".kscc>#ksccFzjc>li{padding: 3px 0px;font-size: 15px;color:#35bee3;overflow-x: hidden;}",

    "li{cursor: pointer}",
    "li:hover{background-color: #0e4c71}",

    // 主页面显示预案操作
    ".rbtns .xsfaclass{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btnseting.png');cursor: pointer}",
    ".rbtns .xsfaclassing{position: relative;margin-right:20px;width: 40px;height: 40px;margin-top: 7.5px;background-image: url('assets/img/fzjc/p_btnseting.png');cursor: pointer}",
    "#yamenu{display: none;position: absolute;left: -30px;top: 45px;width: 130px;height: auto;z-index: 1;background-color: #0B2031}",
    "#yamenu>ul{list-style: none;border: 2px solid #2a95bc;max-height: 180px}",
    "#yamenu>ul>li{ font-size: 15px;color: #35bee3;padding: 5px}",
    "#yamenu .line{height: 1px;width: 100%;border-top: 1px solid #ffffff}",

    //日期
    ".weather{margin-right: 20px;width: auto;height: 55px;line-height:55px;font-size: 20px;color: #35bee3}",
    ".date{margin-right: 20px;width: auto;height: 55px;line-height: 55px; font-size: 20px;color: #35bee3}",
    "iframe{position: absolute;top: 0px;left: 0px;width: 100%;max-height:110px;visibility: inherit;z-index: -1;filter: alpha(opacity=0);opacity: 0;}",

  ]
})

export class FzjctitleComponent implements OnInit, OnDestroy {
  // timeline
  nowtimelabel: string;
  timelineobj: any = {
    kq: "考前",
    kz: "考中",
    kh: "考后"
  };
  // 实时时间  用户名   中间标题
  nowtime: string = "";
  lock: any;
  nowrolename: string = "";
  csid: string = "";
  titlev: string = "";
  //菜单权限
  pageiconlistAll: any[] = [{
    page: "basedeft", //匹配当前路由页面，处理图标
    mc: "准备工作",
    url: "base",
    active: false,
  }, {
    page: "sjgzdeft",
    mc: "试卷流转",
    url: "sjgz",
    active: false,
  }, {
    page: "bmszsdeft",
    mc: "保密室值守",
    url: "bmszs",
    active: false,
  }, {
    page: "kqzldeft",
    mc: "考情总览",
    url: "kqzl",
    active: false,
  }, {
    page: "khtjdeft",
    mc: "考后统计",
    url: "khtj",
    active: false,
  }, {
    page: "sphydeft",
    mc: "视频会议",
    url: "sphy",
    active: false,
  }, {
    page: "p1deft",
    mc: "科目与时间表",
    url: "p1",
    active: false,
  },
  //   {
  //   page: "p11deft",
  //   mc: "科目与时间表2",
  //   url: "p11",
  //   active: false,
  // },
  {
    page: "p2deft",
    mc: "数据总览",
    url: "p2",
    active: false,
  }];
  pageiconlist: any[] = [];
  // 右侧按钮
  rbtnlist: any[] = [];
  // 考试场次
  ksccArr: any[] = [];
  nowccId: string = "";
  nowccmc: string = "";
  ksccselectShow: boolean = false;

  sysBase: string;
  ksxm_kmsjapKeyPath: any = {
    "高考": "p1a",
    "成人高考": "p1b",
    "美术统考": "p1c",
    "研考": "p1d",
    "学考、选考": "p1e",
  }

  /**
   * 左侧页面
   */
  initIcons(): void {
    const timeline = this.o.tlinev;
    this.nowtimelabel = this.timelineobj[timeline];
    const frompage = this.o.frompage;  // active icon
    const aestr_mtmenus = this.localStorageService.get("mtmenus");
    if (!aestr_mtmenus) {
      this.commservice.myswal("warning", "没有该模块任何页面访问权限", "检查用户菜单权限", "ts", null);
      return
    }
    const dastr_mtmenus = this.commservice.daesString(aestr_mtmenus);
    const resp = JSON.parse(dastr_mtmenus); // name url id
    if (resp && resp.length) {
      const hasPages_url = resp.map((item) => {
        const url = item.url; // fzjc_路由
        return url.toString().split("_")[1];
      });
      this.pageiconlist = this.pageiconlistAll.filter((item) => {
        return (hasPages_url.indexOf(item.url) != -1);
      });
      this.pageiconlist.forEach((item) => {
        if (item.page === frompage) {
          item.active = true;
        }
      });
    } else {
      this.commservice.myswal("warning", "没有该模块任何页面访问权限", "检查用户菜单权限", "ts", null);
    }
  }

  /**
   * 右侧按钮控制
   */
  initRbtns(): void {
    const frompage = this.o.frompage;
    switch (frompage) {
      case "basedeft":
      case "khtjdeft":
        this.rbtnlist = [{
          btnkey: "arrow",
          active: false,
          mc: "退出"
        }, {
          btnkey: "xsfa",
          active: false,
          mc: "预案"
        }, {
          btnkey: "ksccselect",
          active: false,
          mc: "考试场次"
        }]
        break;
      case "kqzldeft":
        this.rbtnlist = [{
          btnkey: "arrow",
          active: false,
          mc: "退出"
        }, {
          btnkey: "xsfa",
          active: false,
          mc: "预案"
        }, {
          btnkey: "ksccselect",
          active: false,
          mc: "考试场次"
        }, {
          btnkey: "hylist",
          active: false,
          mc: "视频会议"
        }]
        break;
      case "sphydeft":
        this.rbtnlist = [{
          btnkey: "arrow",
          active: false,
          mc: "退出"
        }, {
          btnkey: "runsphy",
          active: false,
          mc: "视频会议"
        }, {
          btnkey: "ksccselect",
          active: false,
          mc: "考试场次"
        }]
        break;
      default:
        this.rbtnlist = [{
          btnkey: "arrow",
          active: false,
          mc: "退出"
        }, {
          btnkey: "ksccselect",
          active: false,
          mc: "考试场次"
        }];
        break;
    }
  }

  /**
   * 考试场次
   */
  initkscc(): void {
    const ksccliststr = this.localStorageService.get("hcclist");
    if (ksccliststr) {
      const kscclist = JSON.parse(ksccliststr);
      if (kscclist && kscclist.length) {
        this.ksccArr = kscclist;
        this.nowccId = this.localStorageService.get("hkscc");
        this.nowccmc = decodeURIComponent(this.localStorageService.get("hksccmc"));
      }
    }
  }


  /**
   * 页面跳转
   * @param pageicon
   */
  goto(pageicon: any): void {
    if (pageicon.active) {
      return
    }
    const routuerurl = pageicon.url;
    this.commservice.blockUI({
      target: ".main_out",
      boxed: true,
      message: "页面加载中...",
      zIndex: 10051,
      overlayColor: "#196990"
    });
    if (routuerurl == "p1") {
      // 科目与时间表
      // 根据考试项目，判断往哪个页面跳转
      // p1 --- 高考
      //p11 ---成考
      const ksxmmc = decodeURIComponent(this.localStorageService.get("ksxmmc")); // 考试计划列表里么有 考试项目码
      if (!ksxmmc) {
        return
      }
      const pathv = this.ksxm_kmsjapKeyPath[ksxmmc];
      this.router.navigate(["fzjc", pathv]);
    } else {
      this.router.navigate(["fzjc", routuerurl]);
    }
  }


  /**
   * 点击按钮的处理
   * @param btn
   */
  btnHander(btn: any): void {
    const btnkey = btn.btnkey;
    const btnactive = btn.active;
    switch (btnkey) {
      case "ksccselect":
        if (!btnactive) {
          btn.active = true;
          $("#ksccroom").show();
        } else {
          btn.active = false;
          $("#ksccroom").hide();
        }
        break;
      case "runsphy":
        if (!btnactive) {
          btn.active = true;
          // 开启视频会议
          this.outhander.emit({
            type: "sphyctr",
            data: true
          });
        } else {
          btn.active = false;
          // 关闭视频会议
          this.outhander.emit({
            type: "sphyctr",
            data: false
          });
        }
        break;
      case "hylist":
        this.outhander.emit({
          type: "showhylist",
          data: false
        });
        break;
      case "arrow":
        if (this.sysBase === "61") {
          this.router.navigate(["ctrsx"]);
        } else {
          this.router.navigate(["ctrzj"]);
        }
        break;
      case "xsfa":
        if (!btnactive) {
          btn.active = true;
          this.getbjyalist();
          $("#yamenu").show();
        } else {
          btn.active = false;
          $("#yamenu").hide();
        }
        break;
    }
  }

  /**
   * 显示
   * @param e
   */
  showccSelect(e: any): void {
    if (!this.ksccselectShow) {
      this.ksccselectShow = true;
      $("#ksccFzjc").show();
    } else {
      this.ksccselectShow = false;
      $("#ksccFzjc").hide();
    }
    this.commservice.stopBulbble(e);  // 阻止事件冒泡
  }

  /**
   * 选中自定义下拉
   * @param {number} index   2  --考试场次下拉确定    3 ---显示预案下拉确定
   * @param obj
   */
  selectSure(e: any, index: number, obj: any): void {
    switch (index) {
      case 2:
        if (obj.ccm === this.nowccId) {
          this.showccSelect(e);
          return
        }
        this.nowccId = obj.ccm;
        this.nowccmc = obj.ccmc;
        this.showccSelect(e);
        this.localStorageService.set("hkscc", this.nowccId);
        this.localStorageService.set("hksccmc", encodeURIComponent(this.nowccmc));
        this.outhander.emit({
          type: "ksccChange",
          data: {
            ksccbh: this.nowccId
          }
        });
        break;
      case 3:
        if (obj == "setdefault") {
          // 把当前布局设置为和用户相关的默认布局
          this.outhander.emit({
            type: "setdeftbuju",
          });
        } else if (obj == "add") {
          // 把当前布局保存为预案
          this.outhander.emit({
            type: "addya",
          });
        } else if (obj == "yatoggle") {
          // 预案切换，可看该预案的布局效果
          const bjstr = $("#yaselect").val();
          if (bjstr) {
            this.outhander.emit({
              type: "yatoggle",
              data: {
                bjstr: $("#yaselect").val()
              }
            });
          }
        }
        //$("#yamenu").hide();
        break;
    }
    this.commservice.stopBulbble(e);  // 阻止事件冒泡
  }


  /**
   * 获取布局方案列表
   */
  getbjyalist(): void {
    let ssym: string = "";
    const frompage = this.o.frompage;
    if (frompage == "basedeft") {
      ssym = "base"
    } else if (frompage == "kqzldeft") {
      ssym = "kqzl";
    } else if (frompage == "khtjdeft") {
      ssym = "khtj";
    }
    if (!ssym) {
      return
    }
    const url = "ksyw/bj/yaCx";
    this.itservice.kwPtPost(url, {
      ssym: ssym
    }).subscribe(resp => {
      this.commservice.handResponse("get", url, resp, (arg1, resp, arg2) => {
        if (arg1) {
          if (arg2) {
            const yaList = resp.yaList;
            if (yaList && yaList.length) {
              $("#yaselect").empty();
              let optionstr = "";
              yaList.forEach((item) => {
                optionstr += "<option value='" + item.bj + "'>" + item.yaname + "</option>";
              });
              $("#yaselect").append(optionstr);
            }
          } else {
            this.commservice.myswal("warning", resp, "", "ts", null);
          }
        } else {
          this.getbjyalist();
        }
      });
    })
  }

  @Input() o: any;
  @Output() outhander: EventEmitter<any> = new EventEmitter<any>();

  constructor(private router: Router,
    private itservice: MyhttpService,
    private commservice: CommService,
    private localStorageService: LocalStorageService) {

  }

  ngOnInit() {
    this.commservice.getUserinfo((resp) => {
      this.nowrolename = resp.nowrolename ? decodeURIComponent(resp.nowrolename) : this.nowrolename;
      this.csid = resp.csid;
    });
    this.commservice.getSysmsg2((resp) => {
      if (resp) {
        this.sysBase = resp.sysBase;
      }
    });
    this.commservice.getmbzd("gj_xzqhdmb", (resp) => {
      if (resp) {
        const xzbmArr = resp[0];
        let xzmbmc: string = "";
        xzbmArr.forEach((item) => {
          if (item.DM == this.csid) {
            xzmbmc = item.MC;
          }
        });
        this.titlev = `${xzmbmc}教育考试综合管理指挥平台`;
      }
    });
    this.initIcons();
    this.initRbtns();
    this.initkscc();
    this.nowtime = this.commservice.HMS_get(new Date());
    this.lock = setInterval(() => {
      this.nowtime = this.commservice.HMS_get(new Date());
    }, 1000);

  }

  ngOnDestroy() {
    if (this.lock) {
      clearInterval(this.lock);
    }
  }

}
